import csv



train_file = "/home/zuwenqiang/data/MedFMC/MedFMC_train/colon/colon_train.csv"
output_train = "tools/convert/train.txt"

# test_file = "tools/convert/test.csv"
# output_test = "tools/convert/test.txt"

with open(train_file, "r") as file:
    reader = csv.reader(file)
    next(reader)  # 跳过第一行标题

    with open(output_train, "w") as output:
        for row in reader:
            image_id = f'{row[1]}'
            categories = row[-1]
            output.write(f"{image_id} {' '.join(categories)}\n")


# with open(test_file, "r") as file:
#     reader = csv.reader(file)
#     next(reader)  # 跳过第一行标题

#     with open(output_test, "w") as output:
#         for row in reader:
#             if len(row)>0:
#                 image_id = row[0]
#                 categories = row[1]
#                 output.write(f"{image_id}.png {' '.join(categories)}\n")